package addresslist;

import java.util.List;

/**
 * @author mwh
 */
public class Main {

    static String newline = System.getProperty("line.separator");

    public static void main(String[] args) {

        Names names = new Names();

        int N = 100;

        for (int i = 0; i < N; i++) {
            names.addName(generateRandomString(8));
        }

        List<String> namesList = names.getNames();

        System.out.println(newline + "------ List of names ---------");
        for (int i = 0; (i < namesList.size()) && (i < 10); i++) {
            System.out.println(namesList.get(i));
        }

//        System.out.println(newline + "------- Sorting -----------");
//        long a = System.currentTimeMillis();
//
//        namesList = names.getSortedNames();
//
//        long b = System.currentTimeMillis();
//        for (int i = 0; (i < namesList.size()) && (i < 10); i++) {
//            System.out.println(namesList.get(i));
//        }
//        System.out.println(newline + "Sorting: " + (b - a) + "ms");

//        System.out.println(names);
    }

    public static String generateRandomString(int n) {
        StringBuffer sb = new StringBuffer(n);
        int c;
        
        for (int i = 0; i < n; i++) {
            c = 'a' + (int) (Math.random() * 26);
            sb.append((char) c);
        }
        return sb.toString();
    }
}

